package cheme.Interpreter.AST;

import cheme.Interpreter.AST.Interfaces.IAstString;
import cheme.Interpreter.AST.Interfaces.IObserver;
import cheme.Interpreter.AST.Interfaces.SubjectCore;

public class AstString implements IAstString
{
	String string = "";
	
	private SubjectCore subjectCore = new SubjectCore(this);
	
	public AstString()
	{
	}

	public AstString(String string)
	{
		super();
		this.string = string;
	}

	public void setString(String string)
	{
		this.string = string;
		notifyObservers();
	}

	public String getString()
	{
		return string;
	}
	
	@Override
	public String toString()
	{
		return string;
	}
	
	@Override
	public IAstString clone()
	{
		return new AstString(string);
	}
	
	public boolean equals(IAstString string)
	{
		return this.getString().equals(string.toString());
	}
	
	public void attach(IObserver o)
	{
		subjectCore.attach(o);
	}

	public void detach(IObserver o)
	{
		subjectCore.detach(o);
	}

	public void notifyObservers()
	{
		subjectCore.notifyObservers();
	}
}
